<template>
  <div class="info_edit_cont">
    <div class="info_list">
      <el-form ref="form" v-bind="getFormProps()">
        <div class="tem_cont">
          <el-row v-if="summary.value">
            <el-col :span="3">
              <div class="tab_title">
                <b>{{summary.name}}</b>
              </div>
            </el-col>
            <el-col :span="21">
              <div v-if="summary.type == 'textarea'">
                <el-input type="textarea" v-model="summary.valueData" :maxlength="200" :placeholder="summary.placeholder" :rows="5" number-word></el-input>
              </div>
            </el-col>
          </el-row>
        </div>
      </el-form>
    </div>
    <div class="button-box">
      <el-button @click="goBackList">取 消</el-button>
      <el-button type="primary" @click="handleSubmit" :disabled="!summary.valueData">确 定</el-button>
    </div>
  </div>
</template>
<script>
import {form} from 'utils/mixins' // 引入form mixin
import trainApi from 'api/train'
export default {
  mixins: [form],
  props: {
    summary: {
      type: Object,
      default: {}
    },
    editId: {
      type: String,
      default: ''
    },
    isLessonReviewState: {
      type: String,
      default: 'add'
    }
  },
  data () {
    return {
      loading: false, // 必需要返回loading
      form: {}
    }
  },
  methods: {
    handleSubmit: function () { // 提交后台数据
      let type = this.editId ? 'PUT' : 'POST'
      trainApi.editInformation({
        id: this.editId,
        scheduleId: this.$route.query.scheduleid,
        summary: JSON.stringify(this.summary)
      }, type).then((res) => {
        this.$emit('cancelLessonReviewEdit')
      })
    },
    goBackList: function () {
      this.$emit('cancelLessonReviewEdit')
    }
  }
}
</script>
<style lang="scss">
.info_edit_cont{
  margin-bottom:80px;
  .equipment{
    .el-radio{
      margin-bottom:20px;
    }
  }
}
</style>
